package loengud.neljas;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Locale;
import java.util.Scanner;

/**
 * Read from Web.
 * @author ago
 *
 */
public class WebRead {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		/*
		 * Amongst other things - this changes the handling of decimal number 
		 * separator. For example - in Estonian locale you use a comma: 3,14. 
		 * In US, it is: 3.14, with a period "."
		 * Scanner.nextDouble() recognizes 3.1 now.
		 */
		Locale.setDefault(Locale.US);
		

		Scanner sc = null;
		try {
			URL u = new URL("http://iti0010.googlecode.com/svn/branches/" 
					      + "2011/src/loengud/neljas/numbers.raw");
			URLConnection uc = u.openConnection();
			InputStream s = uc.getInputStream();
			//InputStreamReader ir = new InputStreamReader(s);
			//BufferedReader br = new BufferedReader(ir);
			//System.out.println(br.readLine());
			
			sc = new Scanner(s);
			String a = sc.next();
			System.out.println(a);
			//sc.close();
			
			double d = sc.nextDouble();
			System.out.println(d);

			sc.close();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
